/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package machinelearning;
import comparison.cross_validation;
import id3.InputFile;
import id3.Record;
import java.io.IOException;
import java.util.ArrayList;

/**
 *
 * @author SONY VAIO
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException{
        // TODO code application logic here
        ArrayList<Double> knn, naivebayes, tree;
        String nama_file = "data/hayes-roth.data.txt";
        ArrayList<Record> data_awal = InputFile.buildRecords(nama_file);
        int i;
        cross_validation.random_shuffle(data_awal);
        knn = cross_validation.hitung_akurasi(1, nama_file, 10, data_awal);
        naivebayes = cross_validation.hitung_akurasi(2, nama_file, 10, data_awal);
        tree = cross_validation.hitung_akurasi(3, nama_file, 10, data_awal);
        System.out.println("Daftar Perbandingan Akurasi 10-cross validation");
        System.out.println(" ------------------------------------------------------------------------------------------");
        System.out.println("|\tIterasi\t|\tKNN\t|\tNaiveBayes\t|\tID3\t|");
        System.out.println(" ------------------------------------------------------------------------------------------");
        for (i=0; i<10; ++i)
        {
            System.out.print("|\t"+i+"      \t|\t");
            System.out.printf("%.2f", knn.get(i));
            System.out.print("      |\t");
            System.out.printf("%.2f", naivebayes.get(i));
            System.out.print("     \t|\t");
            System.out.printf("%.2f", tree.get(i));
            System.out.println("      |");
            
        }
        System.out.println(" ------------------------------------------------------------------------------------------");
        System.out.println("Daftar Perbandingan t-test");
        System.out.print("knn vs naivebayes  \t:");
        System.out.printf(" %.2f", cross_validation.hitungtPair(knn, naivebayes));
        System.out.println(" %");
        System.out.print("knn vs tree        \t:");
        System.out.printf(" %.2f", cross_validation.hitungtPair(knn, tree));
        System.out.println(" %");
        System.out.print("naivebayes vs tree \t:");
        System.out.printf(" %.2f", cross_validation.hitungtPair(naivebayes,tree));
        System.out.println(" %");
    }

}
